#pragma once

#include <string>
#include "zen_color.h"

namespace Zen { namespace Metal {
	struct RenderID;

	class Render
	{
	protected:
		Render();
		virtual ~Render();
	public:
		static Render * Get();

		void start();

		void end();

		void activeEffect(std::shared_ptr<ShaderKitID> pipe_id);

		void setVertexBuffer(int index, std::shared_ptr<BufferID> buffer, size_t off);

		void setFragmentBuffer(int index, std::shared_ptr<BufferID> buffer, size_t off);
		
		void setFragmentBytes(int index, void const * bytes, size_t len);

		void bindTexture(int index, std::shared_ptr<TextureID> texture);

		void drawPrimitives(eVMode mode, size_t start, size_t count);

		void drawIndexedPrimitives(eVMode mode, size_t count, std::shared_ptr<BufferID> buffer, size_t off_count, size_t step);

		void drawIndexedU32Primitives(eVMode mode, size_t count, std::shared_ptr<BufferID> buffer, size_t off_count);

		void drawIndexedU16Primitives(eVMode mode, size_t count, std::shared_ptr<BufferID> buffer, size_t off_count);

		void setClearColor(Color4f const &);

		/// face.
		void setClockwiseAsFront(bool);

		void cullFace(eFace face);

		void enableDepthTest(bool);

		void setClearDepth(float z);

		void setDepthMask(bool on);

		bool isDepthTestEnabled();

	public:
		RenderID * getID() const;

	protected:
		RenderID * m_id = nullptr;
		Color4f m_clear_color = Color4f(eColor::Black);
		eFace m_cull_face = eFace::None;
		float m_depth_clear = 1.f;
		bool m_clockwise_as_front = 0;
		bool m_depth_test = 0;
		bool m_depth_mask = 0;
	};
}}
